// reducer修改数据的唯一方案
// reducer是一个普通函数，函数参数就是仓库的默认数据
// 这个函数返回的结果，更新仓库数据
const data = { count: 1 }
function countReducer(state = data, action) {
  switch (action.type) {
    case "ADD":
      state.count += action.payload
      return { ...state }
    case "DEL":
      state.count -= action.payload
      return { ...state }
    default:
      return state
  }
}

export default countReducer